package com.darthsith.droidathome.core.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.darthsith.droidathome.core.dao.DeviceDao;
import com.darthsith.droidathome.core.dao.UserDao;
import com.darthsith.droidathome.core.model.Device;
import com.darthsith.droidathome.core.model.User;
import com.darthsith.droidathome.core.service.AuthService;

@Service
public class AuthServiceImpl implements AuthService {

	@Autowired
	private DeviceDao deviceDao;
	
	@Autowired
	private UserDao userDao;
	
	@Override
	@Transactional
	public void addDevice(Device device) {
		deviceDao.addDevice(device);
	}

	@Override
	@Transactional
	public List<Device> listDevice() {
		return deviceDao.listAll();
	}

	@Override
	@Transactional
	public void removeDevice(Device device) {
		deviceDao.removeDevice(device);
	}
	
	@Override
	@Transactional
	public Device getDevice(String macAddress) {
		return deviceDao.getDevice(macAddress);
	}

	@Override
	@Transactional
	public void addUser(User user) {
		userDao.addUser(user);
	}

	@Override
	@Transactional
	public List<User> listUser() {
		return userDao.listAll();
	}

	@Override
	@Transactional
	public void removeUser(User user) {
		userDao.removeUser(user);
	}
	
	@Override
	@Transactional
	public User getUser(String username) {
		return userDao.getUser(username);
	}

}
